//
//  NSBundle+Helper.m
//  lvfj
//
//  Created by lvfeijun on 2020/1/4.
//  Copyright © 2020 Goudu KuaiEx Technology(Shenzhen)Co.,ltd. All rights reserved.
//

#import "NSBundle+Helper.h"

@implementation NSBundle (Helper)

+(NSDictionary *)getInfoDic{
    return [[NSBundle mainBundle] infoDictionary];
}
+(NSString *)getAppVersion{
    return [[NSBundle getInfoDic]  objectForKey:@"CFBundleShortVersionString"];
}
////比较版本的方法，在这里我用的是Version来比较的
+(BOOL)compareVersionsFormAppStore:(NSString*)AppStoreVersion WithAppVersion:(NSString*)AppVersion{
    
    BOOL littleSunResult = false;
    
    NSMutableArray* a = (NSMutableArray*) [AppStoreVersion componentsSeparatedByString: @"."];
    NSMutableArray* b = (NSMutableArray*) [AppVersion componentsSeparatedByString: @"."];
    
    while (a.count < b.count) { [a addObject: @"0"]; }
    while (b.count < a.count) { [b addObject: @"0"]; }
    
    for (int j = 0; j<a.count&&!littleSunResult; j++) {
        littleSunResult = [[a objectAtIndex:j] integerValue] > [[b objectAtIndex:j] integerValue];
    }
    return littleSunResult;//true就是有新版本，false就是没有新版本
}

@end
